package com.celeritymq.session;

import java.io.IOException;
import java.net.SocketAddress;

import javax.jms.JMSException;
import javax.jms.ServerSession;
import javax.jms.Session;

import com.celeritymq.connection.CelerityConnection;
import com.celeritymq.connection.CelerityConnectionImpl;
import com.celeritymq.connection.CelerityQueueConnection;
import com.celeritymq.connection.CelerityTopicConnection;

public class CelerityServerSession extends CeleritySession implements ServerSession {
	private CelerityConnection connection;

	CelerityServerSession(SocketAddress clientAddress, int bufferSize) throws IOException {
		super(clientAddress);
		this.connection = new CelerityConnectionImpl(clientAddress, bufferSize);

	}

	/**
	 * Return the ServerSession's Session. This must be a Session created by the
	 * same Connection that will be dispatching messages to it. The provider
	 * will assign one or more messages to the Session and then call start on
	 * the ServerSession.
	 */
	@Override
	public Session getSession() throws JMSException {
		return this;
	}

	/**
	 * Cause the Session's run method to be called to process messages that were
	 * just assigned to it.
	 */
	@Override
	public void start() throws JMSException {
		run();
	}

}
